import ajax from './ajax'
import mockAjax from '@/mock/mockAjax'

// 1.发送请求获取分类列表数据
export const reqGetCategoryListData = () =>
  ajax.get('/api/product/getBaseCategoryList')

// 2.发送请求获取轮播图数据
export const reqGetBannerListData = () => mockAjax.get('/banner')

// 3.发送请求获取楼层数据
export const reqGetFloorListData = () => mockAjax.get('/floor')

// 4.发送请求搜索商品
export const reqGetGoodsInfo = (searchParams) =>
  ajax.post('/api/list', searchParams)

// 5.发送请求获取详情页数据
export const reqGetGoodsDetailInfo = (id) => ajax.get('/api/item/' + id)

// 6.添加到购物车
export const reqAddOrUpdateCart = (skuId, skuNum) =>
  ajax.post(`/api/cart/addToCart/${skuId}/${skuNum}`)

// 7.发送请求获取购物车数据
export const reqShopCartListData = () => ajax.get('/api/cart/cartList')

// 8.更新购物车中数据的选中状态
export const reqChangeShopCartInfoState = (skuID, isChecked) =>
  ajax.get(`/api/cart/checkCart/${skuID}/${isChecked}`)

// 9.批量更新购物车选中状态
// export const reqUpdateAllShopCartInfoState = (skuIdList, isChecked) =>
//   ajax.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList)
export const reqUpdateAllShopCartInfoState = (skuIdList, isChecked) =>
  ajax({
    url: `/api/cart/batchCheckCart/${isChecked}`,
    method: 'post',
    data: skuIdList,
  })

// 10.删除一条购物车中的数据
export const reqDelOneShopCartInfo = (skuId) =>
  ajax.delete(`/api/cart/deleteCart/${skuId}`)

//11.删除选中商品
export const reqDelSelectCartInfo = (skuIdList) =>
  ajax.delete('/api/cart/batchDeleteCart', skuIdList)

// 12.发送验证码
export const reqGetVerifyCode = (phone) =>
  ajax.get(`/api/user/passport/sendCode/${phone}`)

// 13.注册用户
export const reqRegisterUser = (user) =>
  ajax.post('/api/user/passport/register', user)

// 14.登录
export const reqLogin = (userInfo) =>
  ajax.post('/api/user/passport/login', userInfo)

// 15.登出
export const reqLogout = () => ajax.get('/api/user/passport/logout')

// 16. 获取邮寄地址
export const reqUserAddressList = () =>
  ajax.get('/api/user/userAddress/auth/findUserAddressList')

// 17.获取订单交易页数据
export const reqTradeInfoData = () => ajax.get('/api/order/auth/trade')

// 18.提交订单
export const reqSubmitOrder = (tradeNo, params) =>
  ajax.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`, params)

// 19.获取二维码
export const reqPayQrcode = (orderId) =>
  ajax.get(`/api/payment/weixin/createNative/${orderId}`)

// 20.查询订单是否支付成功
export const reqQueryPayStatus = (orderId) =>
  ajax.get(`/api/payment/weixin/queryPayStatus/${orderId}`)

// 21.获取订单中心数据
export const reqGetOrderListData = (page, limit) =>
  ajax.get(`/api/order/auth/${page}/${limit}`)
